package com.inossem.warehousestorage_inossem.request.refundStorage;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.refundStorage.RefundStorageNewBatchBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * 作者：wsy on 2017/12/19 11:16
 * <p>
 * 邮箱：445979770@qq.com
 */

public class RefundStorageSaleNewBatch extends Request {

    private static final String FACTORY_CODE = "factoryCode"; //工厂代码

    private static final String MATERIRL_CODE = "materielCode"; //物料编码

    private static final String SALE_NUMBER = "saleNumber"; //销售单号

    public static String request(Context context, String factoryCode , String materielCode , String saleNumber, GsonBeanListener gsonBeanListener) {
        String tag;
        Map<String, String> params = new HashMap<>();
        params.put(FACTORY_CODE, factoryCode);
        params.put(MATERIRL_CODE, materielCode);
        params.put(SALE_NUMBER, saleNumber);
        String url = RequestManage.getUrl(context, RequestConstant.URL_REFUND_STORAGE_SALE_NEW_BATCH_LIST + RequestManage.mapEncodeToParams(params));
        tag = RequestManage.getHttpsGetWithLoading(context, url, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                RefundStorageNewBatchBean bean = gson.fromJson(stringRequestResponse.getResponseInfo(), RefundStorageNewBatchBean.class);
                excuteJsonBean(context, bean, bean.getCode(), bean.getMsg(), gsonBeanListener);
            }
        });
        return tag;
    }
}
